package cn.tangshh.universal.core.api;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 返回结果抽象类
 *
 * @author Tang
 * @version v1.0
 * @since 2024/05/30
 */
@Data
@Schema(title = "返回结果")
public abstract class R<T> implements Serializable {
    @Schema(title = "响应码")
    private RCode code;

    @Schema(title = "是否成功：成功true，失败false")
    private boolean success;

    @Schema(title = "响应消息")
    private String msg;

    @Schema(title = "响应数据")
    private T data;

    @Schema(title = "响应时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime time;

    public R() {
        this.time = LocalDateTime.now();
    }
}